package com.ruoyi.order.common;



/**
 * 用户上下文工具类（基于 ThreadLocal）
 */
public class UserContextHolder {
    private static final ThreadLocal<Long> USER_ID_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置当前用户ID
     */
    public static void setUserId(Long userId) {
        USER_ID_THREAD_LOCAL.set(userId);
    }

    /**
     * 获取当前用户ID
     */
    public static Long getUserId() {
        return USER_ID_THREAD_LOCAL.get();
    }

    /**
     * 清除用户ID
     */
    public static void clear() {
        USER_ID_THREAD_LOCAL.remove();
    }
}
